//
//  HWItemCollectionViewCell.m
//  HappyWeekend
//
//  Created by lanou on 16/1/12.
//  Copyright © 2016年 com.mjykj.www. All rights reserved.
//
#define kRow 10
#import "HWItemCollectionViewCell.h"

@implementation HWItemCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat width = frame.size.width;
        _imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width, 376 * width / 481)];
        [self.contentView addSubview:_imageV];
        
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(kRow, _imageV.bottom + kRow, width - 2 * kRow, 50 )];
        _nameLabel.font = [UIFont systemFontOfSize:17];
        _nameLabel.numberOfLines = 0;
        [self.contentView addSubview:_nameLabel];
        
        _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(kRow, _nameLabel.bottom, width / 2, 16)];
        _priceLabel.font = [UIFont systemFontOfSize:14];
        _priceLabel.textColor = [UIColor colorWithRed:58.0f / 255.0f green:201.0f / 255.0f blue:187.0f / 255.0f alpha:1];
        [self.contentView addSubview:_priceLabel];
        
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(_priceLabel.right, _nameLabel.bottom, 16, 16)];
        imageView.image = [UIImage imageNamed:@"itemiconfont-xin"];
        [self.contentView addSubview:imageView];
        
        _favoritesLabel = [[UILabel alloc] initWithFrame:CGRectMake(imageView.right, _nameLabel.bottom, width - imageView.right - kRow, _priceLabel.height)];
        _favoritesLabel.textColor = [UIColor grayColor];
        _favoritesLabel.textAlignment = NSTextAlignmentCenter;
        _favoritesLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_favoritesLabel];
        
        
    }
    return self;
}
- (void)setModel:(HWItemModel *)model{
    _model = model;
    [_imageV sd_setImageWithURL:[NSURL URLWithString:model.cover_image_url] placeholderImage:[UIImage imageNamed:@""]];
    _nameLabel.text = model.name;
    _priceLabel.text = [NSString stringWithFormat:@"%@ %@",@"￥",model.price];
    _favoritesLabel.text = [NSString stringWithFormat:@"%@",model.favorites_count];
    
}







@end
